package com.example8.rabbitmq_module.consume;

import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @Description
 * @Author lihw
 * @Date 2024/1/23 17:24
 */
@Slf4j
@Component
public class CommonConsumer {


    @RabbitListener(queues = "lhw.queue.topic")
    public void consumeMsg(String msg, Message message, Channel channel) throws IOException {
        log.info("result: {}", msg);
        long deliveryTag = message.getMessageProperties().getDeliveryTag();
        // channel.basicReject(deliveryTag, true);
        channel.basicAck(deliveryTag, false);
    }
}
